class GeoServiceTests extends GroovyTestCase {

    //FIXME test more
    void testInPolygon() {
            def p1 =new Point(latitude:44, longitude: 99)
            def p2 =new Point(latitude:44, longitude: 101)
            def p3 =new Point(latitude:46, longitude: 100)
            def p4 = p1

            def plist = []
            plist<<p1
            plist<<p2
            plist<<p3
            plist<<p4

            def service = new GeoService()
            def p = new Point(latitude:45.94000000001, longitude: 100)
            assertTrue service.inPolygon(p,plist)

            def pout = new Point(latitude:45, longitude: 99.2)
            assertFalse service.inPolygon(pout, plist)
    }

    void testGetDistance(){
         //return getDistance(geoPoint1.latitude, geoPoint1.longitude, geoPoint2.latitude, geoPoint2.longitude)
         def p1=new Point("latitude":0 , "longitude":0)
         def p2=new Point("latitude":0 , "longitude":180)
         def service = new GeoService()
         def circle = service.getDistance(p1,p2);
         //println circle
         assertTrue    Math.abs(2*circle-40076) < 40076*0.01
    }


    void testGetLngDiff4Distance(){
        //double getLngDiff4Distance(double lat1, double lng1, double distance) {
        def lat1 = 0
        def lng1 = 0
        def dis = 111;
        def service = new GeoService()
        def diff =  service.getLngDiff4Distance(lat1,lng1,dis);
        println diff
    }
}
